package com.xty.itgroup.tech05tytex.Controller;

import com.xty.itgroup.tech05tytex.Databean.Bean03AxisMain;
import com.xty.itgroup.tech05tytex.Logic.Logic03Axis;
import com.xty.itgroup.tech05tytex.Util.Result;
import com.xty.itgroup.tech05tytex.Util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Copyright ? 2020年 tech05tytex. All rights reserved.
 *
 * @author JinHaoNan
 * TODO: 轴卡接口
 * version 1.0.0
 * @date 2020/10/10 10:39
 */
@Api(value = "AxisController", tags = "轴卡相关接口")
@RestController
@RequestMapping("/axis")
public class AxisController {
    @Autowired
    private Logic03Axis axis;

    //新增轴卡
    /**
     * 单个添加轴卡
     * @param bam
     * @return
     */
    @ApiOperation(value = "添加轴卡", notes = "轴卡+工艺计算新增")
    @RequestMapping(value = "/addaxiscard",method = RequestMethod.POST)
    public Result addAxisCard(@RequestBody Bean03AxisMain bam){
        axis.addAxisCard(bam);
        return ResultUtil.success();
    }
    //轴卡修改
    /**
     * 修改轴卡
     * @param bam
     * @return
     */
    //7轴卡数据修改
    @ApiOperation(value = "修改轴卡", notes = "主键修改轴卡，主表修改，子表删除再新建")
    @RequestMapping(value = "/updateaxiscard",method = RequestMethod.POST)
    public Result updateAxisCard(@RequestBody Bean03AxisMain bam){
        axis.updateAxisCard(bam);
        return ResultUtil.success();
    }
    //轴卡删除
    @ApiOperation(value = "删除轴卡", notes = "根据主键删除")
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    public Result deleteAxis(int mainid){
        axis.deleteById(mainid);
        return ResultUtil.success();
    }

    //轴卡列表
    /**
     * 获取轴卡列表
     * @param orderid
     * @param weavename
     * @param companyid
     * @return
     */
    @ApiOperation(value = "轴卡列表", notes = "根据订单号，品名模糊查询，加工单位精确查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderid", value = "订单编号", required = false, dataType = "String"),
            @ApiImplicitParam(name = "weavename", value = "品名", required = false, dataType = "String"),
            @ApiImplicitParam(name = "companyid", value = "加工单位", required = false, dataType = "int",example = "0")
    })
    @RequestMapping(value = "/listaxiscards",method = RequestMethod.GET)
    public Result listAxisCards(String orderid,String weavename,int companyid){
        return ResultUtil.success(axis.listAxisCard( orderid, weavename, companyid));
    }
    //轴卡详情
    /**
     * 获取轴卡详情
     * @param mainid
     * @return
     */

    //6轴卡详情
    @ApiOperation(value = "获取轴卡详情", notes = "根据主键获取轴卡详情")
    @ApiImplicitParam(name = "mainid", value = "主键", required = true, dataType = "int" , example = "1")
    @RequestMapping(value = "/getcarddetail",method = RequestMethod.GET)
    public Result getAxisCardDetail(int mainid){
        return ResultUtil.success(axis.getAxisCardDetail(mainid));
    }

    /**
     * 根据品名获取配方
     * @param weave_name
     * @return
     */
    @ApiOperation(value = "根据品名获取配方", notes = "根据主键获取工艺配方")
    @ApiImplicitParam(name = "weave_name", value = "品名", required = true, dataType = "String",example = "A600K-UNI-1")
    @RequestMapping(value = "/getaxiscardlines",method = RequestMethod.GET)
    public Result getAxisCardLines1(String weave_name){
        return  ResultUtil.success(axis.getLines(weave_name));
    }

    /**
     * 根据品名获取配方
     * @param company_name
     * @return
     */
    @ApiOperation(value = "获取加工单位列表", notes = "名称模糊搜索")
    @ApiImplicitParam(name = "company_name", value = "品名", required = true, dataType = "String",example = "桃园")
    @RequestMapping(value = "/listcompany",method = RequestMethod.GET)
    public Result listCompany(String company_name){
        return  ResultUtil.success(axis.listCompany(company_name));
    }

}
